package dbexp.model;

import java.util.ArrayList;

import dbexp.model.db.DbOT;

public class SourceType extends DbObject {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	public static final String LABEL = "Typy zrodlowe";
	public static final String DEF_ICON = "icon-cls";
	private ArrayList<Error> errors = new ArrayList<Error>();
	private ArrayList<String> linie = new ArrayList<String>();
	private boolean wrapped = false;

	public SourceType() {
		super(LABEL, DbOT.SOURCE_TYPES);
		setIcons(DEF_ICON);
	};

	public SourceType(String name) {
		super(name, DbOT.SOURCE_TYPE);
		setIcons(DEF_ICON);
		set("leaf", true);
	}

	public SourceType(String name, String schema) {
		this(name);
		setSchema(schema);
	}

	public SourceType(String label2, int functions) {
		super(label2, functions);
	}

	public ArrayList<Error> getErrors() {
		return errors;
	}

	public void setErrors(ArrayList<Error> errors) {
		this.errors = errors;
	}

	public void addErorrs(Error e) {
		this.errors.add(e);
	}

	public void clearErrors() {
		this.errors.clear();
	}

	public String getContent() {
		String out = " ";
		for (int i = 0; i < getLinie().size(); i++) {
			out += getLine(i);
		}
		return out;
	}

	public boolean isWrapped() {
		return wrapped;
	}

	public void setWrapped(boolean wra) {
		this.wrapped = wra;
	}

	public void setLinies(ArrayList<String> linie) {
		this.linie = linie;
	}

	public void setLinies(StringBuffer linie) {
		set("text", linie);
	}

	public ArrayList<String> getLinie() {
		return this.linie;
	}

	public ArrayList<Error> getBledy() {
		return this.errors;
	}

	public void addLine(String line) {
		this.linie.add(line);
	}

	public String getLine(int i) {
		return this.linie.get(i);
	}

	public String getQuery(int operation) {
		return oneFromDual();
	}

	public String printContent() {
		String out = super.printContent();
		for (int i = 0; i < linie.size(); i++) {
			out += linie.get(i) + "\n";
		}
		return out;
	}
}
